<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class News extends Model
{
    protected $table = 'news';

   public function setPictureAttribute($picture)
    {
        if (is_array($picture)) {
            $this->attributes['picture'] = json_encode($picture);
        }
    }

    public function getPictureAttribute($picture)
    {
        return json_decode($picture, true);
    }

    public function newscat()
    {
        return $this->belongsTo(NewsCat::class);
    }

    public function journal()
    {
        return $this->belongsTo(Journal::class);
    }
}
